<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveSupport::CoreExtensions::String::Unicode</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveSupport::CoreExtensions::String::Unicode</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/rails/activesupport/lib/active_support/core_ext/string/unicode_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/string/unicode.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Define methods for handling unicode data.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000734">chars</a>&nbsp;&nbsp;
      <a href="#M000735">is_utf8?</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000734" class="method-detail">
        <a name="M000734"></a>

        <div class="method-heading">
          <a href="#M000734" class="method-signature">
          <span class="method-name">chars</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
<tt><a href="Unicode.html#M000734">chars</a></tt> is a <a
href="Unicode.html">Unicode</a> safe proxy for string methods. It creates
and returns an instance of the <a
href="../../Multibyte/Chars.html">ActiveSupport::Multibyte::Chars</a> class
which encapsulates the original string. A <a
href="Unicode.html">Unicode</a> safe version of all the String methods are
defined on this proxy class. Undefined methods are forwarded to String, so
all of the string overrides can also be called through the <tt><a
href="Unicode.html#M000734">chars</a></tt> proxy.
</p>
<pre>
  name = 'Claus Müller'
  name.reverse #=&gt; &quot;rell??M sualC&quot;
  name.length #=&gt; 13

  name.chars.reverse.to_s #=&gt; &quot;rellüM sualC&quot;
  name.chars.length #=&gt; 12
</pre>
<p>
All the methods on the <a href="Unicode.html#M000734">chars</a> proxy which
normally return a string will return a Chars object. This allows method
chaining on the result of any of these methods.
</p>
<pre>
  name.chars.reverse.length #=&gt; 12
</pre>
<p>
The Char object tries to be as interchangeable with String objects as
possible: sorting and comparing between String and Char work like expected.
The bang! methods change the internal string representation in the Chars
object. Interoperability problems can be resolved easily with a
<tt>to_s</tt> call.
</p>
<p>
For more information about the methods defined on the Chars proxy see <a
href="../../Multibyte/Chars.html">ActiveSupport::Multibyte::Chars</a> and
<a
href="../../Multibyte/Handlers/UTF8Handler.html">ActiveSupport::Multibyte::Handlers::UTF8Handler</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000734-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000734-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/string/unicode.rb, line 30</span>
30:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chars</span>
31:           <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Multibyte</span><span class="ruby-operator">::</span><span class="ruby-constant">Chars</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
32:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000735" class="method-detail">
        <a name="M000735"></a>

        <div class="method-heading">
          <a href="#M000735" class="method-signature">
          <span class="method-name">is_utf8?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns true if the string has UTF-8 semantics (a String used for purely
byte resources is unlikely to have them), returns false otherwise.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000735-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000735-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/string/unicode.rb, line 36</span>
36:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_utf8?</span>
37:           <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Multibyte</span><span class="ruby-operator">::</span><span class="ruby-constant">Handlers</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF8Handler</span>.<span class="ruby-identifier">consumes?</span>(<span class="ruby-keyword kw">self</span>)
38:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>